<?php
session_start();
if (isset($_SESSION["account"])) {
    
    include_once("../untils/conn.php");
    mysqli_query($con, "set names utf8");

    // 获取当前正在登录的账号信息的代理
    $proxy_acc = $_SESSION["account"];
    // echo $proxy_acc ;

    // 防止 SQL 注入攻击
    $proxy_acc = mysqli_real_escape_string($con, $proxy_acc);

    // 查询proxy表，找到符合条件的数据并输出给前端
    $sql = "SELECT * FROM proxy WHERE proxy_acc = '$proxy_acc'";

    $result = mysqli_query($con, $sql);
    if ($result) {
        $rows = mysqli_fetch_assoc($result);
        $puid = $rows["proxy_id"];

        // echo $puid ;


        $sql = "SELECT * FROM shopsy WHERE puid = '$puid'";
        $result = mysqli_query($con, $sql);
        if ($result) {
            $row = mysqli_fetch_assoc($result);
            $link = $row["link"];
            $link_one = $row["link_one"];
            $link_two = $row["link_two"];
            $kefutime = $row["kefutime"];
            $shop_name = $row["shop_name"];
        }
    }
?>

<?php require_once('common/header.php'); ?>
<?php require_once('common/sidebar.php'); ?> 
<div class="main-content app-content mt-0">
    <div class="side-app">
        <div class="main-container container-fluid">
            <div class="card"></div>
            <div class="row row-sm">
                <div class="col-lg-12">
                    <div class="card">
                       
                        <div class="card-body">
                            <form class="was-validated" method="POST" enctype="multipart/form-data" action="Doshop.php">
                                <label for="validationTextarea">店铺昵称</label>
                                <div class="form-row">
                                    <div class="form-group col-md-6 mb-0">
                                        <div class="form-group">
                                            <input type="text" class="form-control" name="shop_name" id="shop_name" placeholder="店铺名称（显示于标题）" value="<?php echo $shop_name ?>">
                                        </div>
                                    </div>
                                </div>
                                <div class="mb-3">
                                    <label for="validationTextarea">客服在线时间</label>
                                    <textarea class="form-control is-invalid" name="kefutime" id="kefutime"
                                        placeholder="请输入客服在线时间列如：客服在线时间：8:00-20:00"   ><?php echo $kefutime ?></textarea>
                                    <div class="invalid-feedback"></div>
                                </div>
                                <div class="input-group is-invalid">
                                    <div class="form-file">
                                        <input type="file" class="form-control" name="kefuurl"
                                            id="kefuurl" >
                                        <label for="validatedInputGroupCustomFile"></label>
                                    </div>
                                </div>
                                <div class="invalid-feedback">客服页的二维码</div>
                                <div class="input-group is-invalid">
                                    <div class="form-file">
                                        <input type="file" class="form-control" name="banner"
                                            id="banner" >
                                        <label for="validatedInputGroupCustomFile"></label>
                                    </div>
                                </div>
                                <div class="invalid-feedback">上传店铺主页轮播图这是第一张</div>
                                <div class="form-row">
                                    <div class="form-group col-md-6 mb-0">
                                        <div class="form-group">
                                            <input type="text" class="form-control" name="link" id="link" placeholder="跳转链接" value="<?php echo $link ?>">
                                        </div>
                                    </div>
                                </div>
                                <div class="input-group is-invalid">
                                    <div class="form-file">
                                        <input type="file" class="form-control" name="banner_one"
                                            id="banner_one" >
                                        <label for="validatedInputGroupCustomFile"></label>
                                    </div>
                                </div>
                                <div class="invalid-feedback">上传店铺主页轮播图这是第二张</div>
                                <div class="form-row">
                                    <div class="form-group col-md-6 mb-0">
                                        <div class="form-group">
                                            <input type="text" class="form-control" name="link_one" id="link_one" placeholder="跳转链接2" value="<?php echo $link_one ?>">
                                        </div>
                                    </div>
                                </div>
                                <div class="input-group is-invalid">
                                    <div class="form-file">
                                        <input type="file" class="form-control" name="banner_two"
                                            id="banner_two" >
                                        <label for="validatedInputGroupCustomFile"></label>
                                    </div>
                                </div>
                                <div class="invalid-feedback">上传店铺主页轮播图这是第三张</div>
                                <div class="form-row">
                                    <div class="form-group col-md-6 mb-0">
                                        <div class="form-group">
                                            <input type="text" class="form-control" name="link_two" id="link_two" placeholder="跳转链接3" value="<?php echo $link_two ?>">
                                        </div>
                                    </div>
                                </div>
                                <input type="hidden" name="puid" value="<?php echo $puid ?>">
                                <div class="form-footer mt-2">
                                    <button type="submit" class="btn btn-primary" style=" padding-left: 80px;padding-right: 80px;">提交</button>
                                </div>
                            </form>
            
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<?php require_once('common/footer.php'); ?>

<?php
} else {
  echo "<script>alert('登录过过期，没有权限访问该页面');location.href='login.html';</script>";
}
